package com.zhihuishu.micro.course ;

import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;

import java.util.Random;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring/beans.xml")
@TransactionConfiguration(defaultRollback = true)
@Transactional
public class SpringIntegrationTestBase {

	protected Logger log = LoggerFactory.getLogger(getClass()) ;
	
	private long startTime ;
	
	@Before
	public void setup() {
		startTime = System.currentTimeMillis() ;
		System.out.println("[方法执行] ----------------------- [开始]");
	}
	
	@After
	public void teardown() {
		System.out.println("[方法执行] ======================= [结束]");
		log.info("方法执行了{}毫秒!" ,System.currentTimeMillis() - startTime) ;
	}

    public int random(int from,int to) {
        return new Random().nextInt(to-from) + from;
    }
    public int random(int to) {
        return random(1,to);
    }
	
}
